/*
* Created by duwanfu on 2018/12/1
* */
export const browserMixin = {
  data() {
    return {
      isWexin: null,
      token:''
    }
  },
  created() {
    this._judgeBrowser();
  },
  methods: {
    _judgeBrowser() {
      let isWeixin = navigator.userAgent.toLowerCase().indexOf('micromessenger') != -1;
      console.log('isWeixin', isWeixin);
      if(!isWeixin) {
        // app
        if(window.android) {
          let token = window.android.getUserToken();
          this.$tools.setCookie('token', token, 30)
          this.token = this.$tools.getCookie('token')
        }
      } else {
        //wxLogin
        let token = this.$tools.getCookie('token')
        if (!token) {
          window.location.href = `http://treasure.jingyugg.com/snsapibase?redirect_uri=${encodeURIComponent(window.location.href)}&redirect_code=loans`
        }
      }
      this.isWexin = isWeixin;
    }
  }
}

export const certificationMixin = {
  data () {
    return {
      _isAuthName: null
    }
  },
  created () {
    this._certification()
  },
  methods: {
    _certification () {
      this.$http.getMineInfo().then(res=>{
        if(res.message == '成功') {
          let data = res.data;
          this._isAuthName = data.isAuthName
        }
      })
    }
  }
}
